use strict;
use warnings;

package Contact::Email;

use base qw(My::DB::Object);

__PACKAGE__->meta->setup(
    table   => 'Email',
    columns => [
        'id'      => { 'type' => 'serial',    'primary_key' => 1,   'not_null' => 1 },
        'address' => { 'type' => 'varchar',   'length'      => 255, 'not_null' => 1 },
        'type'    => { 'type' => 'varchar',   'length'      => 32,  'not_null' => 1 },
        'active'  => { 'type' => 'boolean',   'not_null'    => 1,   'default'  => 1 },
        'created' => { 'type' => 'timestamp', 'not_null'    => 1,   'default'  => 'now' },
        'retired' => { 'type' => 'timestamp', 'not_null'    => 0 },
    ],
    relationships => [
        owners => {
            type        => 'many to many',
            map_class   => 'Contact::PersonEmailMap',
            map_from    => 'email',
            map_to      => 'person',
            add_methods => ['count'],
            }
    ],
);

1;
